<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form" action="{:url('dataCheck')}" method="post" enctype="multipart/form-data">
        <input type="hidden" name="car_id" value="{$car_id}"/>
        <table class="layui-table">
            <tr>
                <td colspan="2" style="font-weight: bold;font-size: 16px;color: black;">快车司机资料审核</td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="司机认证信息" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="hidden" value="<?php echo $info['driver_id'];?>" name="driver_id" id="driver_id">
                                <input type="hidden" value="<?php echo $info['driver_phone'];?>" name="driver_phone" id="driver_phone">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 118px;text-align: center;">真实姓名</td>
                            <td><?php echo $info['driver_name'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">身份证</td>
                            <td><?php echo $info['id_number'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">初次领证日期</td>
                            <td><?php echo $info['license_time'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">驾驶证有效期</td>
                            <td><?php echo $info['valid_time'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">品牌型号</td>
                            <td><?php echo $info['car_brand'];?> - <?php echo $info['car_model'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">车辆颜色</td>
                            <td><?php echo $info['color'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">所有人姓名</td>
                            <td><?php echo $info['owner'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">行驶证车牌号</td>
                            <td><?php echo $info['car_plate'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">发动机号</td>
                            <td><?php echo $info['vin'];?></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">车辆注册日期</td>
                            <td><?php echo $info['register_at'];?></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table class="layui-table">
                                    <tr>
                                        <td style="text-align: center;">身份证(正面)</td>
                                        <td style="text-align: center;">身份证(反面)</td>
                                        <td style="text-align: center;">驾驶证</td>
                                        <td style="text-align: center;">行驶证</td>
                                        <td style="text-align: center;">车辆图片</td>
                                    </tr>
                                    <tr>
                                        <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-00"  src="<?php echo $info['id_front'];?>" style="width: 150px;height: 75px;">
                                            <input name="id_front" id="id_front" type="hidden" value="<?php echo $info['id_front'];?>">
                                            <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-0" >上传图片</button>
                                        </td>
                                        <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-11" src="<?php echo $info['id_back'];?>" style="width: 150px;height: 75px;">
                                            <input name="id_back" id="id_back"  type="hidden" value="<?php echo $info['id_back'];?>">
                                            <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-1" >上传图片</button></td>
                                        <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-22" src="<?php echo $info['license'];?>" style="width: 150px;height: 75px;">
                                            <input name="license"  id="license" type="hidden" value="<?php echo $info['license'];?>">
                                            <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-2" >上传图片</button>
                                        </td>
                                        <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-33" src="<?php echo $info['permit'];?>" style="width: 150px;height: 75px;">
                                            <input name="permit" id="permit"  type="hidden" value="<?php echo $info['permit'];?>">
                                            <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-3" >上传图片</button>
                                        </td>
                                        <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-44" src="<?php echo $info['body_img'];?>" style="width: 150px;height: 75px;">
                                            <input name="body_img" id="body_img" type="hidden" value="<?php echo $info['body_img'];?>">
                                            <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-4" >上传图片</button></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <?php if(!empty($info['time'])):?>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="司机背景信息调查" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">查询结果</td>
                            <td>
                                <?php if($info['backStatus'] == 2):?>
                                <span style="color:green;">查询成功</span>
                                <?php elseif($info['backStatus'] == 1):?>
                                查询中
                                <?php elseif($info['backStatus'] == 0):?>
                                待查询
                                <?php elseif($info['backStatus'] == 3):?>
                                <span style="color:red;">查询失败</span>
                                <?php endif;?>
                            </td>
                        </tr>
                        <?php if($info['backStatus'] == 2):?>
                        <tr>
                            <td style="width: 10%;text-align: center;">前科</td>
                            <td>
                                <?php if(in_array('1',$info['resultContent'])):?>
                                <span style="color:red;">命中</span>
                                <?php else:?>
                                无
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">涉毒/吸毒</td>
                            <td>
                                <?php if(in_array('2',$info['resultContent'])):?>
                                <span style="color:red;">命中</span>
                                <?php else:?>
                                无
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">在逃</td>
                            <td>
                                <?php if(in_array('3',$info['resultContent'])):?>
                                <span style="color:red;">命中</span>
                                <?php else:?>
                                无
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">道德风险</td>
                            <td>
                                <?php if(in_array('4',$info['resultContent'])):?>
                                <span style="color:red;">命中</span>
                                <?php else:?>
                                无
                                <?php endif;?>
                            </td>
                        </tr>
                        <?php endif;?>
                        <tr>
                            <td style="width: 10%;text-align: center;">查询时间</td>
                            <td id="driverInfoTime"><?php echo $info['time'];?></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <?php endif;?>

            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <?php if(!empty($info['taxi']) && !empty($info['taxi_certificate'])):?>
                                <input type="text" class="layui-input" readonly value="运营证信息" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" data-type="certificate" lay-skin="switch" lay-filter="switchCheck" class="check" lay-text="通过|未过" value="1" <?php if($info['taxi_pass'] == 1 && $info['taxi_certificate_pass'] == 1):?>checked<?php endif;?>>
                                <input type="hidden" name="yyzStauts" id="yyzStauts" value="<?php if($info['taxi_pass'] == 1 && $info['taxi_certificate_pass'] == 1):?>1<?php else:?>3<?php endif;?>">
                                <?php else:?>
                                <input type="text" class="layui-input" readonly value="运营证信息 - 暂无" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <?php endif;?>
                            </td>
                        </tr>
                        <?php if(!empty($info['taxi']) && !empty($info['taxi_certificate'])):?>
                        <tr>
                            <td style="width: 10%;text-align: center;">车辆运营证</td>
                            <td class="layer-photos-demo">
                                <img src="<?php echo $info['taxi'];?>" id="taxi_pic" style="width: 150px;height: 75px;">&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="taxi" id="taxi" type="hidden" value="">
                                <button type="button" class="layui-btn taxi"  id="upload-taxi" >上传图片</button>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">司机服务资格证</td>
                            <td class="layer-photos-demo">
                                <img src="<?php echo $info['taxi_certificate'];?>" id="taxi_certificate_pic" style="width: 150px;height: 75px;">&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="taxi_certificate" id="taxi_certificate" type="hidden" value="">
                                <button type="button" class="layui-btn taxi_certificate"  id="upload-taxi_certificate" >上传图片</button>
                            </td>
                        </tr>
                        <?php endif;?>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="保单信息" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" data-type="insurance" lay-skin="switch" lay-filter="switchCheck" class="check" id="checkResult" lay-text="通过|未过" value="1" <?php if($info['comm_pass'] == 1 && $info['sail_pass'] == 1 && $info['carriage_pass'] == 1):?>checked<?php endif;?>>
                                <input type="hidden" name="bdStauts" id="bdStauts" value="<?php if($info['comm_pass'] == 1 && $info['sail_pass'] == 1 && $info['carriage_pass'] == 1):?>1<?php else:?>3<?php endif;?>">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">商业险失效日期</td>
                            <td>
                                <input type="text" class="layui-input" id="commerceinsurance_time" value="<?php echo $info['commerceinsurance_time'];?>" name="commerceinsurance_time" placeholder="yyyy-MM-dd">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">交强险失效日期</td>
                            <td>
                                <input type="text" class="layui-input" id="sail_time" value="<?php echo $info['sail_time'];?>" name="sail_time" placeholder="yyyy-MM-dd">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">承运险失效日期</td>
                            <td>
                                <input type="text" class="layui-input" id="carriage_time" value="<?php echo $info['carriage_time'];?>" name="carriage_time" placeholder="yyyy-MM-dd">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">车辆商业险</td>
                            <td class="layer-photos-demo">
                                <a href="<?php echo $info['commerceinsurance'];?>" target="_blank"><img src="<?php echo $info['commerceinsurance'];?>" id="commerceinsurance_pic" style="width: 150px;height: 75px;"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="commerceinsurance" id="commerceinsurance" type="hidden" value="">
                                <button type="button" class="layui-btn commerceinsurance"  id="upload-commerceinsurance" >上传图片</button>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">车辆交强险</td>
                            <td class="layer-photos-demo">
                                <a href="<?php echo $info['sail'];?>" target="_blank"><img src="<?php echo $info['sail'];?>" id="sail_pic" style="width: 150px;height: 75px;"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="sail" id="sail" type="hidden" value="">
                                <button type="button" class="layui-btn sail"  id="upload-sail}" >上传图片</button>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">车辆承运险</td>
                            <td class="layer-photos-demo">
                                <a href="<?php echo $info['carriage'];?>" target="_blank"><img src="<?php echo $info['carriage'];?>" id="carriage_pic" style="width: 150px;height: 75px;"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="carriage" id="carriage" type="hidden" value="">
                                <button type="button" class="layui-btn carriage"  id="upload-carriage}" >上传图片</button>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="合规标签" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">标签选择</td>
                            <td>
                                <div class="layui-inline">
                                    <select name="compliance_type" id="compliance_type" class="layui-input" style="width: 200px;">
                                        <?php foreach($compliance as $key=>$value):?>
                                        <option value="<?php echo $key;?>" <?php if($key == $info['compliance_type']):?>selected<?php endif;?>><?php echo $value;?></option>
                                        <?php endforeach;?>
                                    </select>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="审核结果" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" data-type="checkResult" lay-skin="switch" lay-filter="switchCheck" class="check" lay-text="通过|未过" value="1" <?php if($info['taxi_pass'] == 1 && $info['taxi_certificate_pass'] == 1 && $info['comm_pass'] == 1 && $info['sail_pass'] == 1 && $info['carriage_pass'] == 1):?>checked<?php endif;?>>
                                <input type="hidden" name="dataStatus" id="dataStatus" value="<?php if($info['taxi_pass'] == 1 && $info['taxi_certificate_pass'] == 1 && $info['comm_pass'] == 1 && $info['sail_pass'] == 1 && $info['carriage_pass'] == 1):?>1<?php else:?>3<?php endif;?>" >
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">未通过原因</td>
                            <td>
                                <textarea rows="3" class="layui-textarea" name="remark" id="remark"  maxlength="80" placeholder="请输入未通过原因"><?php echo $info['taxi_reason'];?></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 10%;text-align: center;">可选择标签</td>
                            <td>
                                <?php foreach($car_check_data as $key=>$value):?>
                                <input class="layui-input" type="checkbox" lay-filter="reasonType" value="<?php echo $value;?>" title="<?php echo $value;?>">
                                <?php endforeach;?>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <button class="layui-btn submitBtn" lay-submit="" id="submit" lay-filter="submit">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </form>
    <script>
        layui.use(['form','laydate', 'upload'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,upload = layui.upload, laydate = layui.laydate;
            layer.photos({
                photos: '.layer-photos-demo'
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
            });
            var k;
            var id_str;
            var num;
            upload.render({
                elem: '.uploads'//这个就等同于点击
                ,url: '/admin/Upload/uploadImg'

                ,before: function(obj){
                    id_str=this.item.context.id;

                    //预读本地文件示例，不支持ie8
                }
                ,done:  function(res){ //上传后的回调
                    var arr=id_str.split("-");
                    var num=arr[2];
                    if(res.status == 1){
                        $("#"+id_str+num+"").css('display','');
                        $("#"+id_str+num+"").attr('src',res.data.file); //点击后的大图
                        $("#"+id_str+num+"").attr('layer-src',res.data.file_thumb); //小图
                        num=parseInt(num);
                        switch (num){
                            case 0:$("#id_front").val(res.data.file);break;
                            case 1:$("#id_back").val(res.data.file);break;
                            case 2:$("#license").val(res.data.file);break;
                            case 3:$("#permit").val(res.data.file);break;
                            case 4:$("#body_img").val(res.data.file);break;
                        }
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                }
            });
            //运营证
            upload.render({
                elem: '.taxi'//这个就等同于点击
                ,url: '/admin/Upload/upload'
                ,done:  function(res){ //上传后的回调
                    //console.log(res)
                    if(res.status == 1){
                        $("#taxi_pic").attr('src',res.data.file); //点击后的大图
                        $("#taxi").val(res.data.file);
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    //console.log(e)
                    //layer.msg('上传失败');

                }
            });
            upload.render({
                elem: '.taxi_certificate'//这个就等同于点击
                ,url: '/admin/Upload/upload'
                ,done:  function(res){ //上传后的回调
                    console.log(res)
                    if(res.status == 1){
                        $("#taxi_certificate_pic").attr('src',res.data.file); //点击后的大图
                        $("#taxi_certificate").val(res.data.file);
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                    //layer.msg('上传失败');

                }
            });
            //保单
            upload.render({
                elem: '.commerceinsurance'//这个就等同于点击
                ,url: '/admin/Upload/upload'
                ,done:  function(res){ //上传后的回调
                    console.log(res)
                    if(res.status == 1){
                        $("#commerceinsurance_pic").attr('src',res.data.file); //点击后的大图
                        $("#commerceinsurance").val(res.data.file);
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                    //layer.msg('上传失败');

                }
            });
            upload.render({
                elem: '.sail'//这个就等同于点击
                ,url: '/admin/Upload/upload'
                ,done:  function(res){ //上传后的回调
                    console.log(res)
                    if(res.status == 1){
                        $("#sail_pic").attr('src',res.data.file); //点击后的大图
                        $("#sail").val(res.data.file);
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                    //layer.msg('上传失败');

                }
            });
            //承运险
            upload.render({
                elem: '.carriage'//这个就等同于点击
                ,url: '/admin/Upload/upload'
                ,done:  function(res){ //上传后的回调
                    console.log(res)
                    if(res.status == 1){
                        $("#carriage_pic").attr('src',res.data.file); //点击后的大图
                        $("#carriage").val(res.data.file);
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                    //layer.msg('上传失败');

                }
            });
            //常规用法
            laydate.render({
                elem: '#commerceinsurance_time'
            });
            laydate.render({
                elem: '#sail_time'
            });
            laydate.render({
                elem: '#carriage_time'
            });
            form.on('switch(switchCheck)', function(data){
                if(!this.checked){
                    var value = 0;
                }else{
                    var value = 1;
                }
                var key_name = $(this).data('type');
                var car_id = $("input[name='car_id']").val();
                //运营证审核
                if(key_name == 'certificate'){
                    if(value == 1){
                        $('#yyzStauts').val(1);
                    }else{
                        $('#yyzStauts').val(3);
                    }
                }
                //保单审核
                if(key_name == 'insurance'){
                    if(value == 1){
                        $('#bdStauts').val(1);
                    }else{
                        $('#bdStauts').val(3);
                    }
                }
                //审核结果
                if(key_name == 'checkResult'){
                    if(data.elem.checked == true){
                        $('#dataStatus').val(1);
                    }else{
                        $('#dataStatus').val(3);
                    }
                }
                if(key_name == 'certificate' || key_name == 'insurance'){
                    $.post('{:U("check_one")}',{'name':key_name,'value':value,'car_id':car_id},function(data){
                        console.log(data)
                    })
                }
            });
            form.on('checkbox(reasonType)', function(data){
                var remark = $("#remark").val();
                if(data.elem.checked == true){
                    if(remark == ''){
                        remark = data.value;
                    }else{
                        remark = remark+';'+data.value;
                    }
                }else{
                    var reg = new RegExp(data.value+';',"g");//g,表示全部替换。
                    var remark = remark.replace(reg,"");
                    var rega = new RegExp(data.value,"g");//g,表示全部替换。
                    var remark = remark.replace(rega,"");
                }
                $("#remark").val(remark);
            });
            //监听提交
            form.on('submit(submit)', function(data){
                //点击通过
                if($("#dataStatus").val() != 1 && $("#remark").val() ==''){
                    layer.msg('请填写未通过原因',{icon: 5});return false;
                }
                //按钮置灰  防止多次提交
                $(".submitBtn").addClass('layui-btn-disabled');
            });
        });

    </script>
</block>
